/* Copyright (C) 2008, 2009, 2010 Faindu GmbH, Switzerland.
* All Rights Reserved. The following is Source Code and is subject to all restrictions 
* on such code as contained in the license accompanying this project. */
package blocstac.editimage.base
{
	
	import flash.geom.Point;
	
	import org.mockito.MockitoTestCase;
	
	public class SizeProperties_isOnImageTest extends MockitoTestCase
	{
		function SizeProperties_isOnImageTest() {
			super([ViewModel])
		}
		
		//==========================================================================
		//
		//  Test set up and tear down
		//
		//--------------------------------------------------------------------------  
		private var _viewModel:ViewModel
		private var _sizeProperties:SizeProperties
		
		override public function setUp(): void {
			_viewModel = mock(ViewModel, null, [null])
			given(_viewModel.componentView2imageSpace(any())).will(new ReturnArg(0))
			_sizeProperties = new SizeProperties(_viewModel)
		}
		override public function tearDown():void {
		}
		
		//==========================================================================
		//
		//  Tests
		//
		//--------------------------------------------------------------------------  
		[Test]
		public function test_isOnImage(): void {
			given(_viewModel.imageWidthUnscaled).willReturn(10)
			given(_viewModel.imageHeightUnscaled).willReturn(10)
			
			assertTrue(_sizeProperties.isOnImage(new Point(1, 1)))
			assertTrue(_sizeProperties.isOnImage(new Point(0, 9)))
		}
		
		[Test]
		public function test_isOnImage_oustide_bottom_or_right(): void {
			given(_viewModel.imageWidthUnscaled).willReturn(10)
			given(_viewModel.imageHeightUnscaled).willReturn(10)
			
			assertFalse(_sizeProperties.isOnImage(new Point(1, 11)))
			assertFalse(_sizeProperties.isOnImage(new Point(11, 1)))
		}
		
		[Test]
		public function test_isOnImage_oustide_left_or_top(): void {
			assertFalse(_sizeProperties.isOnImage(new Point(-1, 1)))
			assertFalse(_sizeProperties.isOnImage(new Point(1, -1)))
		}
		
	}
}